 ModScan Help Index

Overview (MODBUS)

Protocol

Messages

Error Detection

Exception Responses

Overview (ModScan Application)

Operation

Display

Commands

Setup Serial

Setup Display

Setup Protocol

Start/Stop Polling

How To ...

Connect to a Slave Device

Read Data Points

Write Data Points

Monitor Serial Activity


MODBUS Protocol

The MODBUS protocol describes an industrial communications and distributed control system developed by Gould-Modicon to integrate PLCs, computers, terminals, and other monitoring, sensing, and control devices.  MODBUS is a Master/Slave communications protocol, whereby one device, (the Master), controls all serial activity by selectively polling one or more slave devices.  The protocol provides for one master device and up to 247 slave devices on a common line.  Each device is assigned an address to distinguish it from all other connected devices.

Only the master initiates a transaction.  Transactions are either a query/response type, (only a single slave is address), or a broadcast/no response type, (all slaves are addressed).  A transaction comprises a single query and single response frame or a single broadcast frame.

Certain characteristics of the MODBUS protocol are fixed, such as the frame format, frame sequences, handling of communications errors and exception conditions, and the functions performed.

Other characteristics are user selectable.  These include a choice of transmission media, baud rate, character parity, number of stop bits, and the transmission modes, (ASCII or RTU).   The user selected parameters are set, (hardwired or programmed), at each station.  These parameters cannot be changed while the system is running.

Modes of Transmission

The mode of transmission is the structure of the individual units of information within a message, and the numbering system used to transmit the data.  Two modes of transmission are available for use in a MODBUS system.  Both modes provide the same capabilities for communicating with PLC slaves;  the mode is selected depending on the equipment used as a MODBUS Master.  One mode must be used per MODBUS system; mixing of modes is not allowed.  The modes are ASCII (American Standard Code for Information Interchange), and RTU, (Remote Terminal Unit.)  The characteristics of the two transmission modes are defined below:

Characteristic	ASCII (7-bit)	RTU (8-bit)
Coding System	hexadecimal (uses ASCII printable characters (0-9, A-F)	8-bit binary
Number of bits per character:
start bits	1	1
data bits (least significant first)	7	8
parity (optional)	1	1
	(1-bit sent for even or odd parity, no bits for no parity)	(1-bit sent for even or odd parity, no bits for no parity)
stop bits	1 or 2	1 or 2
Error Checking	LRC (Longitudinal Redundancy Check)	CRC (Cyclical Redundancy Check)

ASCII printable characters are easy to view when troubleshooting and this mode is suited to computer masters programmed in a high level language, such as FORTRAN, as well as PLC masters.  RTU is suited to computer masters programmed in a machine language, as well as PLC masters.

In the RTU mode, data is sent in 8-bit binary characters.  In the ASCII mode, each RTU character is first divided into two 4-bit parts, (high order and low order), and then represented by the hexadecimal equivalent.  The ASCII characters representing the hexadecimal characters are used to construct the message.  The ASCII mode uses twice as many characters as the RTU mode, but decoding handling the ASCII data is easier.  Additionally, in the RTU mode, message characters must be transmitted in a continuous stream.  In the ASCII mode, breaks of up to one second can occur between characters to allow for a relatively slower master.


Error Detection

There are two types of errors which may occur in a communications system: transmission errors and programming errors.  The MODBUS system has specific methods for dealing with either type of error.

Communications errors usually consist of a changed bit or bits within a message.  The most frequent cause of communications errors is noise: unwanted electrical signals in a communications channel.  These signals occur because of electrical interference from machinery, damage to the communications channel, impulse noise, (spikes), etc.  Communications errors are detected by character framing, a parity check, and a redundancy check.

When the character framing, parity, or redundancy checks detect a communications error, processing of the message stops.  A PLC slave will not act on or respond to the message.  (The same occurs if a non-existent slave address is used.)

When a communications error occurs, the message is unreliable.  The PLC slave cannot know for sure if this message was intended for it.  So the CPU might be answering a message which was not its message to begin with.  It is essential to program the MODBUS Master to assume a communications error has occurred if there is no response in a reasonable time.  The length of this time depends upon the baud rate, type of message, and scan time of the PLC slave.  Once this time is determined, the master may be programmed to automatically retransmit the message.

The MODBUS system provides several levels of error checking to assure the quality of the data transmission.  To detect multibit errors where the parity has not changed, the system uses redundancy checks: Cyclical Redundancy Check, (CRC), for the RTU mode and Longitudinal Redundancy Check, (LRC), for the ASCII mode.

CRC-16 Cyclic Redundancy Check

The CRC-16 error check sequence is implemented as described in the following paragraphs.

The message, (data bits only, disregarding start/stop and parity bits), is considered as one continuous binary number whose most significant bit, (MSB), is transmitted first.  The message is pre-multiplied by X**16, (shifted left 16 bits), then divided by X**16 + X**15 + X**2 + 1 expressed as a binary number (11000000000000101).  The integer quotient digits are ignored and the 16-bit remainder (initialized to all ones at the start to avoid the case where all zeroes being an accepted message), is appended to the message, (MSB first), as the two CRC check bytes.  The resulting message including the CRC, when divided by the same polynomial (X**16 + X**15 + X**2 + 1), at the receiver will give a zero remainder if no errors have occurred.  (The receiving unit recalculates the CRC and compares it to the transmitted CRC).  All arithmetic is performed modulo two, (no carries).  An example of the CRC-16 error check for message HEX 0207, (address 2, function 7 or a status request to slave number 2) follows:

The device used to serialize the data for transmission will send the conventional LSB or right-most bit of each character first.  In generating the CRC, the first bit transmitted is defined as the MSB of the dividend.  For convenience then, and since there are no carries used in arithmetic, lets assume while computing the CRC that the MSB is on the right.  To be consistent, the bit order of the generating polynomial must be reversed.  The MSB of the polynomial is dropped since it affects only the quotient and not the remainder.  This yields 1010 0000 0000 0001, (HEX A001)..  Note that this reversal of the bit order will have no effect whatever on the interpretation or the bit order of characters external to the CRC calculations.

The step by step procedure to form the CRC-16 is as follows:

1.	Load a 16-bit register with all 1s.

2.	Exclusive OR the first 8-bit byte with the high order byte of the 16-bit register, putting the result in the 16-bit register.

3.	Shift the 16-bit register one bit to the right.

4a.	If the bit shifted out to the right is one, exclusive OR the generating polynomial 1010 0000 0000 0001 with the 16-bit register.

4b.	If the bit shifted out to the right is zero; return to step 3.

5.	Repeat steps 3 and 4 until 8 shifts have been performed.

6.	Exclusive OR the next 8-bit byte with the 16-bit register.

7.	Repeat step 3 through 6 until all bytes of the message have been exclusive ORrd with the 16-bit register and shifted 8 times.

8.	The contents of the 16-bit register are the 2 byte CRC error check and is added to the message most significant bits first.

	16-BIT REGISTER	MSB			Flag
(Exclusive OR)	1111	1111	1111	1111
02			0000	0010
	1111	1111	1111	1101
Shift 1	0111	1111	1111	1110	1
Polynomial	1010	0000	0000	0001
	1101	1111	1111	1111
Shift 2	0110	1111	1111	1111	1
Polynomial	1010	0000	0000	0001
	1100	1111	1111	1110
Shift 3	0110	0111	1111	1111	0
Shift 4	0011	0011	1111	1111	1
Polynomial	1010	0000	0000	0001
	1001	0011	1111	1110
Shift 5	0100	1001	1111	1111	0
Shift 6	0010	0100	1111	1111	1
Polynomial	1010	0000	0000	0001
	1000	0100	1111	1110
Shift 7	0100	0010	0111	1111	0
Shift 8	0010	0001	0011	1111	1
Polynomial	1010	0000	0000	0001
	1000	0001	0011	1110
07			0000	0111
	1000	0001	0011	1001
Shift 1	0100	0000	1001	1100	1
Polynomial	1010	0000	0000	0001
	1110	0000	1001	1101
Shift 2	0111	0000	0100	1110	1
Polynomial	1010	0000	0000	0001
	1101	0000	0010	1111
Shift 3	0110	1000	0010	0111	1
Polynommial	1010	0000	0000	0001
	1100	1000	0010	0110
Shift 4	0110	0100	0001	0011	0
Shift 5	0011	0010	0000	1001	1
Polynomial	1010	0000	0000	0001
	1001	0010	0000	1000
Shift 6	0100	1001	0000	0100	0
Shift 7	0010	0100	1000	0010	0
Shift 8	0001	0010	0100	0001	0
	HEX 12			HEX 41
TRANSMITTED MESSAGE WITH CRC-16

(MESSAGE SHIFTED TO RIGHT TO TRANSMIT)

       12                   41                    07                   02

0001    0010    0100    0001    0000    0111    0000    0010

LRC (Longitudinal Redundancy Check)

The error check sequence for the ASCII mode is LRC.  The error check is an 8-bit binary number represented and transmitted as two ASCII hexadecimal (hex) characters.  The error check is produced by converting the hex characters to binary, adding the binary characters without wraparound carry, and twos complementing the result.  At the received end the LRC is recalculated and compared to the sent LRC.  The colon, CR, LF, and any imbedded non-ASCII hex characters are ignored in calculating the LRC.

Address	02		0000 0010
Function	01		0000 0001
Start Add H.O.	00		0000 0000
Start Add L.O.	00		0000 0000
Quantity of Pts	00		0000 0000
	08		0000 1000
		Sum	0000 1011
		1s complement	1111 0100
		+1	0000 0001
Error Check	F5	2s complement	1111 0101


MODBUS Message Types

ASCII Framing

Framing in ASCII Transmission mode is accomplished by the use of the unique colon, (:), character to indicate the beginning of frame and carriage return/line feed, (CRLF), to delineate end of frame.  The line feed character also serves as a synchronizing character which indicates that the transmitting station is ready to receive an immediate reply.

BEGIN FRAME	ADDRESS	FUNCTION	DATA	ERROR CHECK	EOF	READY TO RECEIVE
:	2-CHAR 16-BIT	2-CHAR 16-BITS	N X 4-CHAR N X 16-BITS	2-CHAR 16-BITS	CR	LF

RTU Framing

Frame synchronization can be maintained in RTU transmission mode only by simulating a synchronous message.  The receiving device monitors the elapsed time between receipt of characters.  If three and one-half character times elapse without a new character or completion of the frame, then the device flushes the frame and assumes that the next byte received will be an address.

T1,T2,T3	ADDRESS	FUNCTION	DATA	CHECK	T1,T2,T3
	8-BITS	8-BITS	N X 8-BITS	16-BITS

Address Field

The address field immediately follows the beginning of frame and consists of 8-bits, (RTU), or 2 characters, (ASCII).   These bits indicate the user assigned address of the slave device that is to receive the message sent by the attached master.

Each slave must be assigned a unique address and only the addressed slave will respond to a query that contains its address.  When the slave sends a response, the slave address informs the master which slave is communicating.  In a broadcast message, an address of 0 is used.  All slaves interpret this as an instruction to read and take action on the message, but not to issue a response message.

Function Field

The Function Code field tells the addressed slave what function to perform.  MODBUS function codes are specifically designed for interacting with a PLC on the MODBUS industrial communications system.  The high order bit in this field is set by the slave device to indicate an exception condition in the response message.  If no exceptions exist, the high-order bit is maintained as zero in the response message.

The following table lists those functions supported by the ModScan application:

CODE	MEANING	ACTION
01	READ COIL STATUS	Obtains current status, (ON/OFF), of a group of logic coils.
02	READ INPUT STATUS	Obtains current status, (ON/OFF), of a group of discrete inputs.
03	READ HOLDING REGISTER	Obtains current binary value in one or more holding registers.
04	READ INPUT REGISTER	Obtains current binary value in one or more input registers.
05	FORCE SINGLE COIL	Force logic coil to a state of ON or OFF.
06	PRESET SINGLE REGISTER	Place a specific binary value into a holding register.

Data Field

The data field contains information needed by the slave to perform the specific function or it contains data collected by the slave in response to a query.  This information may be values, address references, or limits.  For example, the function code tells the slave to read a holding register, and the data field is needed to indicate which register to start at and how many to read.  The imbedded address and data information varies with the type and capacity of the PLC associated with the slave.

Error Check Field

This field allows the master and slave devices to check a message for errors in transmission.  Sometimes, because of electrical noise or other interference, a message may be changed slightly while its on its way from one device to another.  The error checking assures hat the slave or master does not react to messages that have changed during transmission.  This increases the safety and the efficiency of the MODBUS system.

The error check field uses a Longitudinal Redundancy Check, (LRC), in the ASCII mode of transmission, and a CRC-16 check in the RTU mode.


Exception Responses

Programming or operation errors are those involving illegal data in a message, no response from the PLC to its interface unit, or difficulty in communicating with a slave.  These errors result in an exception response from either the master computer software or the PLC slave, depending on the type of error.  The exception response codes are listed below.  When a PLC slave detects one of these errors, it sends a response message to the master consisting of the slave address, function code, error code, and error check fields.  To indicate that the response is a notification of an error, the high-order bit of the function code is set to one.

CODE	NAME	MEANING
01	ILLEGAL FUNCTION	The message function received is not an allowable action for the addressed slave.
02	ILLEGAL DATA ADDRESS	The address referenced in the data field is not an allowable address for the addressed slave device.
03	ILLEGAL DATA VALUE	The value referenced in the data field is not allowable in the addressed slave location.
04	FAILURE IN ASSOCIATED DEVICE	The slaves PC has failed to respond to a message or an abortive error occurred.
05	ACKNOWLEDGE	The slave PLC has accepted and is processing the long duration program command.
06	BUSY, REJECTED MESSAGE	The message was received without error, but the PLC is engaged in processing a long duration program command.
07	NAK-NEGATIVE ACKNOWLEDGMENT	The PROGRAM function just requested could not be performed.


Help menu commands

The Help menu offers the following commands, which provide you assistance with this application:

Index	Offers you an index to topics on which you can get help.
Using Help	Provides general instructions on using help.
About	Displays the version number of this application.


Read Output Status
READ OUTPUT STATUS (FUNCTION CODE 01)

This function allows the user to obtain the ON/OFF status of logic coils used to control discrete outputs from the addressed slave only.  Broadcast mode is not supported with this function code.  In addition to the slave address and function fields, the message requires that the information field contain the initial coil address to be read, (Starting Address), and the number of locations that will be interrogated to obtain status data.

The addressing allows up to 2000 coils to be obtained at each request; however, the specific slave device may have restrictions that lower the maximum quantity.  The coils are numbered from zero; (coil number 1 is address 0000, coil number 2 is address 0001, etc.)

The following is an example of a message to Read Output Status Coils 20-56 from slave device number 17.

ADDR	FUNC	DATA START PT HO	DATA START PT LO	DATA # OF PTS HO	DATA # OF PTS LO	ERROR CHECK FIELD
11	01	00	13	00	25	B6

An example response to Read Output Status is shown below.  The data is packed one bit for each coil.  The response includes the slave address, function code, quantity of data characters, and error checking.  Data will be packed with one bit with one bit for each coil, (1 = ON, 0 = OFF).  The low order bit of the first character contains the addressed coil, and the remainder follow.  For coil quantities that are not even multiples of eight, the last characters will be filled in with zeroes at the high end.  The quantity of data characters is always specified as the quantity of RTU characters, i.e., the number is the same whether RTU or ASCII is used.

ADDR	FUNC	BYTE COUNT	DATA COIL STATUS 20-27	DATA COIL STATUS 28-35	DATA COIL STATUS 36-43	DATA COIL STATUS 44-51	DATA COIL STATUS 52-56	ERROR CHECK FIELD
11	01	05	CD	6B	B2	0E	1B	D6

The status of coils 20-27 is shown as CD(HEX) = 1100 1101(Binary).  Reading left to right, this shows that coils 27,26,23,22, and 20 are all on.  The other coil data bytes are decoded similarly.


Read Input Status
READ INPUT STATUS (FUNCTION CODE 02)

This function allows the user to obtain the ON/OFF status of discrete inputs in the addressed slave.  Broadcast mode is not supported.  In addition to the slave address and function code fields, this message requires that the information field contain the initial input address to be read, (Starting Address) and the number of locations that will be interrogated to obtain the status data.

The following is an example of a message to Read Input Status Coils 10197-10218 from slave device number 17.

ADDR	FUNC	DATA START PT HO	DATA START PT LO	DATA # OF PTS HO	DATA # OF PTS LO	ERROR CHECK FIELD
11	02	00	C4	00	16	13

An example response to Read Input Status is shown below.  The data is packed one bit for each coil.  The response includes the slave address, function code, quantity of data characters, and error checking.  Data will be packed with one bit with one bit for each coil, (1 = ON, 0 = OFF).  The low order bit of the first character contains the addressed coil, and the remainder follow.  For coil quantities that are not even multiples of eight, the last characters will be filled in with zeroes at the high end.  The quantity of data characters is always specified as the quantity of RTU characters, i.e., the number is the same whether RTU or ASCII is used.

ADDR	FUNC	BYTE COUNT	DATA DISCRETE INPUT 10197-10204	DATA DISCRETE INPUT 10205-10212	DATA DISCRETE INPUT 10213-10218	ERROR CHECK FIELD
11	02	03	AC	DB	35	2E	LRC

The status of inputs 10197-10204 is shown as AC (HEX) = 1010 1100 (Binary).  Reading left to right, this shows that inputs 10204, 10202, 10200 and 10099 are all on.  The other input data bytes are decoded similarly.


Read Output Registers
READ OUTPUT REGISTERS (FUNCTION CODE 03)

Read Output Registers allows the user to obtain the binary contents of holding registers in the addressed slave.

These registers can store the numerical values of associated timers and counters which can be driven to external devices.

The addressing allows up to 125 registers to be obtained at each request; however, the specified slave device may have restrictions that lower this maximum quantity.  The registers are numbered from zero, broadcast mode is not allowed.

The following example reads registers 40108 through 40110 from slave number 17.

ADDR	FUNC	DATA START PT HO	DATA START PT LO	DATA # OF REGS HO	DATA # OF REGS LO	ERROR CHECK FIELD
11	03	00	6B	00	03	7E
The addresses slave responds with its address and the function code, followed by the information field.  The information field contains 2 bytes describing the quantity of data bytes to be returned.  The contents of the registers requested (DATA), are two bytes each, with the binary content right justified within each pair of characters.  The first byte includes the high order bits and the second, low order bits.

In the example below, the registers 40108-40110 have the decimal contents 555, 0, and 100 respectively.

ADDR	FUNC	BYTE COUNT	DATA OUTPUT REG H.O. 40108	DATA OUTPUT REG L.O. 40108	DATA OUTPUT REG H.O. 40109	DATA OUTPUT REG L.O. 40109	DATA OUTPUT REG H.O. 40110	DATA OUTPUT REG L.O. 40110	ERROR CHECK FIELD
11	03	06	02	2B	00	00	00	64	55


Read Input Registers
READ INPUT REGISTERS (FUNCTION CODE 04)

Function Code 04 obtains the contents of the controllers input registers.  These locations receive their vales from devices connected to the I/O structure and can only be referenced, not altered from within the controller nor via MODBUS.

The example below requests the contents of register 30009 in slave number 17.

ADDR	FUNC	DATA START PT HO	DATA START PT LO	DATA # OF REGS HO	DATA # OF REGS LO	ERROR CHECK FIELD
11	04	00	08	00	01	E2

In the response message, the contents of register 30009 is decimal value 0.

ADDR	FUNC	BYTE COUNT	DATA INPUT REG HO 30009	DATA INPUT REG LO 30009	ERROR CHECK FIELD
11	04	02	00	00	E9


Force Single Coil
FORCE SINGLE COIL (FUNCTION CODE 05)

This message forces a single coil either On of OFF.  Any coil that exists within the controller can be forced to either state, (ON or OFF).  Coils are numbered from zero (i.e. coil 1 is address 0000, coil 2 is address 0001, etc.).  The data value 65,280, (FF00 HEX) will set the coil ON and the value zero will turn it off.  All other values are illegal and will not effect the coil.  The use of slave address 00, (Broadcast mode), will force all attached slaves to modify the desired coil.

The example below requests slave number 17 to turn coil number 0173 ON.

ADDR	FUNC	DATA COIL HO	DATA COIL LO	DATA # ON/OFF	DATA	ERROR CHECK FIELD
11	05	00	AC	FF	00	3F

The normal response to the command request is to retransmit the message as received, after the coil state has been altered.

ADDR	FUNC	DATA COIL HO	DATA COIL LO	DATA # ON/OFF	DATA	ERROR CHECK FIELD
11	05	00	AC	FF	00	3F


Preset Single Register
PRESET SINGLE REGISTER (FUNCTION CODE 06)

Function 06 allows the user to modify the contents of a holding register.  Any holding register that exists within the controller can have its contents changed by this message.  The values are provided in binary up to the maximum capacity of the controller.  Unused high-order bits must be set to zero.  When used with slave address 00, all slave controllers will load the specified register with the contents specified.

ADDR	FUNC	DATA REG HO	DATA REG LO	DATA  VALUE HO	DATA VALUE  LO	ERROR CHECK FIELD
11	06	00	87	03	9E	C1

The normal response to a preset single register request is to retransmit the query message after the register has been altered.

ADDR	FUNC	DATA REG HO	DATA REG LO	DATA  VALUE HO	DATA VALUE  LO	ERROR CHECK FIELD
11	06	00	87	03	9E	C1


ModScan Display

The display of the ModScan application consists of two parts.  The top half of the display represents the addressing information which specifies the remote slave device and data point type to scan.  The bottom half of the display typically represents the results of the most recent data scan but may be configured to show serial data traffic if desired.

The top half of the display contains typical dialog box controls which allow specification of the Slave Device address, and MODBUS  message type, as well as the starting address and number of data points to read.  Values may be changed during an active polling session and will take effect on the next scheduled poll.

To the right of the display are two counters representing the number of query messages attempted and the number of valid responses received.  During an active polling session, ModScan will attempt to poll the specified slave device periodically depending on the poll cycle selected.  These counters may be reset via a menu command and are useful for picking up intermittent failures over an extended period of time.

Immediately above the horizontal line separating the addressing data from the actual data point display is a status line representing current activity of the ModScan application.  During an active polling session, this line will represent any exception responses received from the addressed slave device or any communications errors which may result from an invalid address specification or disconnected serial line.

If ModScan is configured to display MODBUS data points, Coil values will be displayed as below.  ON status is displayed as 1, OFF as 0.  ModScan will attempt to display all data points defined by the Length parameter in the address specification using the available Window display area.

10001:  <1>	10009:  <0>	10017:  <1>
10002:  <0>	10010:  <0>	10018:  <0>
10003:  <0>	10011:  <0>	10019:  <0>
10004:  <0>	10012:  <0>	10020:  <0>
10005:  <1>	10013:  <1>
10006:  <0>	10014:  <0>
10007:  <0>	10015:  <0>
10008:  <0>	10016:  <0>

Register values may be displayed in either Decimal or Hexadecimal notation.  The address of each data point is followed by the contents as shown below:  (Hexadecimal notation would include an H after the value such as 1000H.)

40010:  <01234>	40018:  <00000>	40026:  <0000>
40011:  <00000>	40019:  <00000>	40027:  <00000>
40012:  <00000>	40020:  <00000>	40028:  <00000>
40013:  <00000>	40021:  <00000>	40029:  <00000>
40014:  <00001>	40022:  <00010>	40030:  <00000>
40015:  <00000>	40023:  <00100>
40016:  <00000>	40024:  <00000>
40017:  <00000>	40025:  <00000>

If ModScan is configured to display actual serial data, each character transmitted and received by the application will be displayed to the bottom portion of the screen as they occur.  Data polls originating from the master device will be displayed in reverse video, (White characters on a Black background).  Data characters received from a slave device will be displayed in normal video.

*** NOTE ***

Data characters representing outgoing data, (initiated by the ModScan application), are displayed as they are sent to the appropriate PC COM port for transmission.  This does not indicate that the characters have been actually transmitted nor received by the addressed remote.  If the serial cable is not correct, or the RS-232 handshaking lines are not configured properly, the application will appear as though data characters are being transmitted, when in effect they are not making it past the UART.


ModScan Overview

The ModScan application operates as a MODBUS master device in either RTU or ASCII transmission modes.  ModScan may be used to access and modify data points contained in any connected MODBUS slave device.  The user specifies the addressing information to access the slave device using the supported message types 01-04.  Data is scanned on a cyclic basis and displayed on the screen as received.  The user may change the contents of a slave device data point by exercising the MODBUS message types 05 or 06.

ModScan allows complete control over the physical communications protocol by providing menu options to select the baud rate, parity, etc., as well as the RS-232 control signals such as RTS/CTS.  Menu options also allow the user to specify the MODBUS transmission mode, message time-out, and scan frequency.


Setup Serial Menu Command

The SetUp Serial menu command allows the user to control the physical characteristics of the MODBUS connection.  The PC COM port to use may be selected, as well as the baud rate, number of stop bits, and parity.  The RTU transmission mode dictates that 8 data bits are used while the ASCII mode of transmission allows either 7 or 8 data bits to be used, (even though the eighth bit is not used).

The RS-232 handshaking lines may be configured by checking the appropriate boxes depending on the characteristics required by the connected slave device.


File Exit command
Exit command (File menu)

Use this command to end your ModScan session.  You can also use the Close command on the application Control menu.


Setup Display Characteristics
Setup Display Menu Commands

The SetUp Display Menu consists of four line items representing two mutually exclusive options.  The display may be configured to display data points or serial traffic by clicking on the appropriate menu selection.  The option in effect is represented by a check mark.  Likewise, register data may be displayed in either decimal or hexadecimal notation depending on the menu item selected.  To change from one notation to the other, simply click the unchecked option.


Setup Protocol
Setup Protocol Menu Commands

The Setup Protocol Menu commands allow the user to specify either RTU or ASCII transmission modes.  The transmission mode may not be changed wile an active session is in progress.  The polling cycle must be stopped before these menu options are activated.

The polling cycle and associated message time-out are also configurable via the Setup Protocol Menu Commands.  The polling cycle represents the time delay between successive polls and is specified in seconds:

The message time-out determines how long the ModScan application waits for a response from an addressed slave device and is specified in milliseconds:


Start/Stop Polling
Start/Stop Polling Menu Commands

These menu commands initiate or stop a ModScan polling cycle.  The Start Polling Menu command begins a repetitive cycle of polling the slave device specified in the addressing section of the display.  The device to poll and the point type and addressing parameters may be changed at any time during a polling cycle.  As data is received from the slave device, it is displayed in the data point section of the screen.  The Stop Polling Menu selection simply halts the polling process and returns the ModScan application to an Idle condition.


Connecting to MODBUS Slave
How to:  Connect to a MODBUS slave device

The physical device characteristics of the particular slave device determines the communications parameters required for connection.  MODBUS is a multidrop communications protocol, (software), but typical RS-232 serial connections are not.  RS-232 is basically a point-to-point hardware protocol with the transmit line of one device connected to the receive line of another device.  Various combinations of protocol converters and/or modems may be used to multidrop RS-232 data links.  Additionally, some PC serial cards may be configured to support 20 ma current loop for multidrop operation.

If a single slave device is to be connected to the ModScan application, standard RS-232 hardware may be used.  Depending upon the requirements of the slave device, certain control signals may be required.  These are typically RTS/CTS, (pins 4&5), or DTR/DSR/DCD, (pins 6,8 & 20).  ModScan supports these control signals which may be activated via the Setup Serial Menu Command.  In general, if pins 4&5 are jumpered together and pins 6,8 & 20 are jumpered together at the slave end of the cable, the ModScan application should work without activating the control signals.  If the slave requires the inputs, the jumpers will allow it to operate without support from the PC.  If the inputs are not required, the jumpers dont have any effect.


Reading Data Points
How to:  Read Slave Data Points

To initiate a polling session with a particular MODBUS slave device, simply enter the address of the connected device and click on the Start Menu Command.  The MODBUS message type, slave point address and number of data points to read are defined by the edit controls represented on the top half of the ModScan display.  If errors occur during the polling cycle, they will be displayed in the status line directly above the data point display.  As values are obtained from the addressed slave, they will be shown on the ModScan display.  ModScan will continue to poll the specified slave device based on the polling cycle specified via the Setup Protocol Menu Commands.  If a different slave device is to be accessed, or different points within a device, the edit controls may be changed during a polling cycle.  Changes will be in effect on the next poll.


Writing Data Points
How to: Write a Slave Data Point

In order to write a MODBUS data point in a slave device, the communications with the device must first be initiated by scanning a series of data points by configuring the correct addressing information and initiating a polling cycle.  Once the data is successfully displayed on the screen, double-clicking the address/value portion of the screen will initiate a dialog box which allows the value to be changed.  If the polling cycle has been configured to represent coil addresses, double-clicking an address will initiate the Change Coil Dialog:

The Change Register Dialog Box may be initiated by configuring the display to represent register data and double clicking on an address:

Pressing the Update Button in either write data point dialog will initiate the appropriate MODBUS write command, (05 or 06), during the next scheduled poll.


Monitoring Serial Traffic
How to:  Monitor Serial Data Traffic

In certain cases, it may be desirable to monitor the actual MODBUS communications between the ModScan application and a particular slave device.  The application allows the serial data traffic to be displayed to the screen as it occurs by selecting the View Traffic option under the Setup Display Menu Command options.

If enabled, the bottom portion of the ModScan display will depict all serial data characters transmitted and received as they occur.  Transmitted characters are displayed in reverse video, received characters are displayed in normal video.  Display of the actual serial traffic is sometimes useful for troubleshooting an intermittent communications fault or debugging a new design.


View Status Bar Command
Status Bar command (View menu)

Use this command to display and hide the Status Bar, which describes the action to be executed by the selected menu item or depressed toolbar button, and keyboard latch state. A check mark appears next to the menu item when the Status Bar is displayed.

See Status Bar for help on using the status bar.


Status Bar

The status bar is displayed at the bottom of the <<YourApp>> window.  To display or hide the status bar, use the Status Bar command in the View menu.

The left area of the status bar describes actions of menu items as you use the arrow keys to navigate through menus.  This area similarly shows messages that describe the actions of toolbar buttons as you depress them, before releasing them.  If after viewing the description of the toolbar button command you wish not to execute the command, then release the mouse button while the pointer is off the toolbar button.

The right areas of the status bar indicate which of the following keys are latched down:

Indicator	Description

CAP	The Caps Lock key is latched down.

NUM	The Num Lock key is latched down.

SCRL	The Scroll Lock key is latched down.


New command (Window menu)

Use this command to open a new window with the same contents as the active window.  You can open multiple document windows to display different parts or views of a document at the same time.  If you change the contents in one window, all other windows containing the same document reflect those changes.  When you open a new window, it becomes the active window and is displayed on top of all other open windows.


Cascade command (Window menu)

Use this command to arrange multiple opened windows in an overlapped fashion.


Tile command (Window menu)

Use this command to arrange multiple opened windows in a non-overlapped fashion.


Tile Horizontal command (Window menu)

Use this command to vertically arrange multiple opened windows in a non-overlapped fashion.


Tile Vertical command (Window menu)

Use this command to arrange multiple opened windows side by side.


Window Arrange Icons Command

Use this command to arrange the icons for minimized windows at the bottom of the main window.  If there is an open document window at the bottom of the main window, then some or all of the icons may not be visible because they will be underneath this document window.


1, 2, ... command (Window menu)

<<YourApp>> displays a list of currently open document windows at the bottom of the Window menu.  A check mark appears in front of the document name of the active window.  Choose a document from this list to make its window active.


Index command (Help menu)

Use this command to display the opening screen of Help.  From the opening screen, you can jump to step-by-step instructions for using <<YourApp>> and various types of reference information.

Once you open Help, you can click the Contents button whenever you want to return to the opening screen.


Using Help command (Help menu)

Use this command for instructions about using Help.


About command (Help menu)

Use this command to display the copyright notice and version number of your copy of <<YourApp>>.


Help Using Help Command
Context Help command

Use the Context Help command to obtain help on some portion of <<YourApp>>.  When you choose the Toolbar's Context Help button, the mouse pointer will change to an arrow and question mark.  Then click somewhere in the <<YourApp>> window, such as another Toolbar button.  The Help topic will be shown for the item you clicked.

Shortcut

Keys:	SHIFT+F1


Title Bar

<< Show your application's title bar here. >>

The title bar is located along the top of a window.  It contains the name of the application and document.

To move the window, drag the title bar.  Note: You can also move dialog boxes by dragging their title bars.

A title bar may contain the following elements:

Application Control-menu button

Document Control-menu button

Maximize button

Minimize button

Name of the application

Name of the document

Restore button


Scroll bars

Displayed at the right and bottom edges of the document window.  The scroll boxes inside the scroll bars indicate your vertical and horizontal location in the document.  You can use the mouse to scroll to other parts of the document.

<< Describe the actions of the various parts of the scrollbar, according to how they behave in your application. >>


Size command (System menu)

Use this command to display a four-headed arrow so you can size the active window with the arrow keys.

After the pointer changes to the four-headed arrow:

1.	Press one of the DIRECTION keys (left, right, up, or down arrow key) to move the pointer to the border you want to move.

2.	Press a DIRECTION key to move the border.

3.	Press ENTER when the window is the size you want.

Note:  This command is unavailable if you maximize the window.

Shortcut

Mouse:	Drag the size bars at the corners or edges of the window.


Move command (Control menu)

Use this command to display a four-headed arrow so you can move the active window or dialog box with the arrow keys.

Note:  This command is unavailable if you maximize the window.

Shortcut

Keys:	CTRL+F7


System Minimize Command
Minimize command (application Control menu)

Use this command to reduce the <<YourApp>> window to an icon.

Shortcut

Mouse:	Click the minimize icon [image] on the title bar.

Keys:	ALT+F9


Maximize command (System menu)

Use this command to enlarge the active window to fill the available space.

Shortcut

Mouse:	Click the maximize icon [image] on the title bar; or double-click the title bar.

Keys:	CTRL+F10 enlarges a document window.


Next Window command (document Control menu)

Use this command to switch to the next open document window.  <<YourApp>> determines which window is next according to the order in which you opened the windows.

Shortcut

Keys:	CTRL+F6


Previous Window command (document Control menu)

Use this command to switch to the previous open document window.  <<YourApp>> determines which window is previous according to the order in which you opened the windows.

Shortcut

Keys:	SHIFT+CTRL+F6


Close command (Control menus)

Use this command to close the active window or dialog box.

Double-clicking a Control-menu box is the same as choosing the Close command.

Note:  If you have multiple windows open for a single document, the Close command on the document Control menu closes only one window at a time.  You can close all windows at once with the Close command on the File menu.

Shortcuts

Keys: 	CTRL+F4 closes a document window

ALT+F4 closes the <<YourType>> window or dialog box


Restore command (Control menu)

Use this command to return the active window to its size and position before you chose the Maximize or Minimize command.


Switch to command (application Control menu)

Use this command to display a list of all open applications.  Use this "Task List" to switch to or close an application on the list.

Shortcut

Keys:	CTRL+ESC

Dialog Box Options

When you choose the Switch To command, you will be presented with a dialog box with the following options:

Task List

Select the application you want to switch to or close.

Switch To

Makes the selected application active.

End Task

Closes the selected application.

Cancel

Closes the Task List box.

Cascade

Arranges open applications so they overlap and you can see each title bar.  This option does not affect applications reduced to icons.

Tile

Arranges open applications into windows that do not overlap.  This option does not affect applications reduced to icons.

Arrange Icons

Arranges the icons of all minimized applications across the bottom of the screen.


View Ruler Command
Ruler command (View menu)

<< Write application-specific help here. >>


Choose Font Dialog
Choose Font dialog box

<< Write application-specific help here. >>


Choose Color Dialog
Choose Color dialog box

<< Write application-specific help here. >>


Edit Find Command
Find command (Edit menu)

<< Write application-specific help here. >>


Find Dialog
Find dialog box

<< Write application-specific help here. >>


Edit Replace Command
Replace command (Edit menu)

<< Write application-specific help here. >>


Replace Dialog
Replace dialog box

<< Write application-specific help here. >>


Edit Repeat Command
Repeat command (Edit menu)

Use this command to repeat the last editing command carried out.  The Repeat menu item changes to Can't Repeat if you cannot repeat your last action.

Shortcut

Key:	F4


Edit Clear Command
Clear command (Edit menu)

<< Write application-specific help here. >>


Edit Clear All
Clear All command (Edit menu)

<< Write application-specific help here. >>


Next Pane Command
Next Pane

<< Write application-specific help here. >>


Prev Pane Command
Prev Pane

<< Write application-specific help here. >>


Modifying the Document

<< Write application-specific help here that provides an overview of how the user should modify a document using your application.

If your application supports multiple document types and you want to have a distinct help topic for each, then use the help context i.d. generated by running the MAKEHELP.BAT file produced by AppWizard.  Alternatively, run MAKEHM as follows:

makehm IDR_HIDR_,0x2000 resource.h

If the IDR_ symbol for one of your document types is, for example, IDR_CHARTTYPE, then the help context i.d. generated by MAKEHM will be HIDR_CHARTTYPE.

Note, AppWizard defines the HIDR_DOC1TYPE help context i.d. used by this help topic for the first document type supported by your application.  AppWizard produces an alias in the .HPJ file for your application, mapping HIDR_DOC1TYPE to the HIDR_ produced by MAKEHM for that document type. >>


No Help Available

No help is available for this area of the window.


No Help Available

No help is available for this message box.

<< If you wish to author help specific to each message box prompt, then remove the AFX_HIDP_xxx values from the [ALIAS] section of your .HPJ file, and author a topic for each AFX_HIDP_xxx value.  For example, AFX_HIDP_INVALID_FILENAME is the help topic for the Invalid Filename message box. >>


File Print command
Print command (File menu)

Use this command to print a document.   This command presents a Print dialog box, where you may specify the range of pages to be printed, the number of copies, the destination printer, and other printer setup options.

Shortcuts

Toolbar:

Keys:	CTRL+P


Print dialog box

The following options allow you to specify how the document should be printed:

Printer

This is the active printer and printer connection.  Choose the Setup option to change the printer and printer connection.

Setup

Displays a Print Setup dialog box, so  you can select a printer and printer connection.

Print Range

Specify the pages you want to print:

All	Prints the entire document.
Selection	Prints the currently selected text.
Pages	Prints the range of pages you specify in the From and To boxes.
Copies

Specify the number of copies you want to print for the above page range.

Collate Copies

Prints copies in page number order, instead of separated multiple copies of each page.

Print Quality

Select the quality of the printing.  Generally, lower quality printing takes less time to produce.


Print Progress Dialog

The Printing dialog box is shown during the time that <<YourApp>> is sending output to the printer.  The page number indicates the progress of the printing.

To abort printing, choose Cancel.


File Print Preview command
Print Preview command (File menu)

Use this command to display the active document as it would appear when printed.  When you choose this command, the main window will be replaced with a print preview window in which one or two pages will be displayed in their printed format.  The print preview toolbar offers you options to view either one or two pages at a time; move back and forth through the document; zoom in and out of pages; and initiate a print job.


Print Preview toolbar

The print preview toolbar offers you the following options:

Print

Bring up the print dialog box, to start a print job.

Next Page

Preview the next printed page.

Prev Page

Preview the previous printed page.

One Page / Two Page

Preview one or two printed pages at a time.

Zoom In

Take a closer look at the printed page.

Zoom Out

Take a larger look at the printed page.

Close

Return from print preview to the editing window.


File Print Setup command
Print Setup command (File menu)

Use this command to select a printer and a printer connection.  This command presents a Print Setup dialog box, where you specify the printer and its connection.


Print Setup dialog box

The following options allow you to select the destination printer and its connection.

Printer

Select the printer you want to use.  Choose the Default Printer; or choose the Specific Printer option and select one of the current installed printers shown in the box.  You install printers and configure ports using the Windows Control Panel.

Orientation

Choose Portrait or Landscape.

Paper Size

Select the size of paper that the document is to be printed on.

Paper Source

Some printers offer multiple trays for different paper sources.  Specify the tray here.

Options

Displays a dialog box where you can make additional choices about printing, specific to the type of printer you have selected.

Network...

Choose this button to connect to a network location, assigning it a new drive letter.


File Page Setup Command
Page Setup command (File menu)

<< Write application-specific help here. >>